// src/api/api.ts
import request from "@/utils/request";

/**
 * 获取商品列表
 * @param data
 * @returns
 */
export const getGoodsListApi = (params: any) => {
  return request({
    url: "/api/goods/list",
    method: "GET",
    params: params,
  });
};

/**
 * 新建或者更新商品
 * @param data
 * @returns
 */
export const saveOrUpdateGoodsApi = (data: any) => {
  return request({
    url: "/api/goods/saveOrUpdate",
    method: "POST",
    data: data,
  });
};

/**
 * 删除商品
 * @param id '商品Id'
 * @returns
 */
export const deleteGoodsApi = (id: number) => {
  return request({
    url: `/api/goods/delete/${id}`,
    method: "DELETE",
  });
};

/**
 * 获取单个商品
 * @param id
 * @returns
 */
export const getGoodsByIdApi = (id: number) => {
  return request({
    url: `/api/goods/getGoods/${id}`,
    method: "GET",
  });
};
